package com.dgsrz.demo.util;

import android.util.Log;

/**
 * Created by dgsrz on 15/7/2.
 */
public enum FPSLogger {

    INSTANCE;

    private long mLastCheckpoint;
    private int mFinishedFrames;

    FPSLogger() {
        mLastCheckpoint = System.currentTimeMillis();
    }

    public void finishGLDraw() {
        mFinishedFrames++;
        long currentTime = System.currentTimeMillis();
        if (currentTime - mLastCheckpoint >= 1000) {
            Log.d("FPSLogger", "FPS: " + mFinishedFrames);
            mFinishedFrames = 0;
            mLastCheckpoint = currentTime;
        }
    }
}
